package HibernateOrederManagement.app;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import HibernateOrderManagerment.bean.User;

public class UsernameExistsDao {
	
	private Session session;
	public UsernameExistsDao(Session session){
		this.session=session;
	}
	
	public boolean isUsernameExists(String username){
		Criteria criteria =session.createCriteria(User.class);
		criteria.add(Restrictions.eq("username", username));
		List<?> list =criteria.list();
		if(list.size()>0){
			return true;
		}
		return false;
	}

}
